package com.joker.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.support.ResourceScriptSource;

@Configuration
public class LuaConfig {

    @Bean(value = "lua-inventory")
    public DefaultRedisScript<Long> luaInventory() {

        DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();

        redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("redis/skuInventory.lua")));

        redisScript.setResultType(Long.class);

        return redisScript;
    }


}
